## 20ms 2984KB 1/4超时


num=int(input())

named={}
for i in range(num):
    id,score = input().split()
    named.setdefault(id,0)
    named[id]+=int(score)


# ans=sorted(named.items(),key=lambda x:x[1])
# print(*ans[-1]) 
maxnum=max(named.items(),key=lambda x:x[1])
print(*maxnum)



"""
20ms 2944KB 1个超时
"""
def lltry(num):

    sch=[0]*(num+1)

    for row in range(1,num+1):
        a,b=[int(i) for i in input().split()]
        sch[a]+=b # FIX 

    maxnum=max(sch)
    print(sch.index(maxnum),maxnum,end="")

